package com.buptlogistics.creditinvestigation.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.buptlogistics.creditinvestigation.R;
import com.buptlogistics.creditinvestigation.activity.CommonActivity;
import com.buptlogistics.creditinvestigation.app.BaseFragment;

/**
 * 付款承诺书
 */
public class ContractPayFragment extends BaseFragment {


    private View view;

    private Button btn_accept;
    private TextView tv_content;


    public ContractPayFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_contract_pay, container, false);
        initViews();
        initEvents();
        return view;
    }

    protected void initViews() {
        btn_accept = (Button) findViewById(R.id.btn_contract_pay_accept);
        tv_content = (TextView) findViewById(R.id.tv_contract_pay_content);
        String html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
                "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
                "<head>\n" +
                "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" +
                "<title>付款承诺书</title>\n" +
                "</head>\n" +
                "\n" +
                "<body>\n" +
                "<p><strong>上海证明物流有限公司：</strong></p>\n" +
                "<p><strong>好羊羊</strong>于<strong>2015年12月26日</strong>签订了编号为<strong>xxx</strong>的买卖合同，合同金额为<strong>xxx</strong>元，现我公司知悉<strong>xx张三</strong>已在贵公司申请上述合同项下的应收账款保理业务，我司已收到合同项下发票号码为<strong>xxx</strong>、金额为<strong>xxx</strong>元的全部货物，并已检验合格。我司在此不可撤销承诺承担上述贷款的到期全部付款业务（到期日<strong>xxx</strong>），不以任何包括上述上午合同执行中的争议等为理由拒付。</p>\n" +
                "<p>本承诺书子作出之日起，至应收账款全部付清之日止保持有效。</p>\n" +
                "<blockquote>\n" +
                "  <p>承诺人 好羊羊</p>\n" +
                "</blockquote>\n" +
                "</body>\n" +
                "</html>\n";

        tv_content.setMovementMethod(ScrollingMovementMethod.getInstance());//滚动
        tv_content.setText(Html.fromHtml(html));
    }

    protected void initEvents() {
        btn_accept.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle data = new Bundle();
                data.putInt("fragmentType", 7);
                // 创建一个Intent
                Intent intent = new Intent(ContractPayFragment.this.getActivity(),
                        CommonActivity.class);
                intent.putExtras(data);
                // 启动intent对应的Activity
                startActivity(intent);
            }
        });
    }

    protected View findViewById(int id) {
        return view.findViewById(id);
    }

}
